package com.wanxi.servlet;

import com.wanxi.model.*;
import com.wanxi.service.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author Li
 * @Date 2023/4/27 10:28
 */
@WebServlet("/FirmIndex")
public class FirmIndexServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        乱码解决
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
//        接收前端数据
//        封装model
//        调用服务层
        CompanyService companyService = new CompanyService();
        NavService navservice = new NavService();
        AreaService areaservice = new AreaService();
        LawyerService lawyerservice =new LawyerService();
        NewService newservice = new NewService();
        StrengthService strengthService = new StrengthService();
        CustomerService customerService =new CustomerService();

//        返回给前端
        CompanyModel companyModel = companyService.getCompany();
        List<CustomerModel> customerModels = customerService.getCustomer();
        List<CustomerModel> customerModels1 = customerService.getCustomer1();
        List<NavModel>  NavModelList = navservice.getNav();
        List<NavModel> NavModelList1 = navservice.getNav1();
       List<AreaModel> AreaModelList = areaservice.getArea();
       List<AreaModel> AreaModelList1 = areaservice.getArea1();
        List<LawyerModel> lawyerModelList = lawyerservice.getIndexLawyer();
        List<NewsModel> newsModelList = newservice.getIndexNews();
        StrengthModel strengthModel = strengthService.getStrength();
        req.setAttribute("company",companyModel);
        req.setAttribute("customerModels",customerModels);
        req.setAttribute("customerModels1",customerModels1);
        req.setAttribute("nav",NavModelList);
        req.setAttribute("nav1",NavModelList1);
        req.setAttribute("area",AreaModelList);
        req.setAttribute("area1",AreaModelList1);
        req.setAttribute("lawyer",lawyerModelList);
        req.setAttribute("news",newsModelList);
        req.setAttribute("strength",strengthModel);
        req.getRequestDispatcher("/jsp/index.jsp").forward(req,resp);
    }
}
